package com.zhny.aiot.standard.valve.v2.plugin;

import com.zhny.aiot.plugin.ICenterFacilities;
import com.zhny.aiot.plugin.IDevice;
import com.zhny.aiot.plugin.model.CommandEntry;
import com.zhny.aiot.plugin.model.DeviceEntity;
import com.zhny.aiot.plugin.model.FactoryType;
import com.zhny.aiot.plugin.model.StoreEntity;
import com.zhny.aiot.plugin.v2.gateway.GatewayV2Engine;
import com.zhny.aiot.plugin.v2.gateway.GatewayV2Server;
import com.zhny.aiot.plugin.zhnygateway.GatewayServer;
import com.zhny.aiot.plugin.zhnygateway.device.ZhnyDeviceFactory;
import com.zhny.aiot.standard.valve.v2.plugin.model.StandardV2Device;
import com.zhny.aiot.standard.valve.v2.plugin.model.StandardValveV2StoreEntry;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;

import java.util.List;

public class StandardValveV2Plugin extends Plugin {
    public StandardValveV2Plugin(PluginWrapper wrapper) {
        super(wrapper);
    }
    @Extension
    public static class StandardValveFactory extends ZhnyDeviceFactory<StandardValveV2StoreEntry> {

        @Override
        public List<CommandEntry> supportCommandClasses() {
            List<CommandEntry> commands = super.supportCommandClasses ();
            commands.add(CommandEntry.valueOf("openValve1", "A阀门打开","无参数",null));
            commands.add(CommandEntry.valueOf("closeValve1", "A阀门关闭","无参数", null));
            commands.add(CommandEntry.valueOf("openValve2", "B阀门打开","无参数", null));
            commands.add(CommandEntry.valueOf("closeValve2", "B阀门关闭","无参数", null));
            commands.add(CommandEntry.valueOf("openValve3", "C阀门打开","无参数" ,null));
            commands.add(CommandEntry.valueOf("closeValve3", "C阀门关闭","无参数" ,null));
            commands.add(CommandEntry.valueOf("openValve4", "D阀门打开", "无参数",null));
            commands.add(CommandEntry.valueOf("closeValve4", "D阀门关闭", "无参数",null));
            commands.add(CommandEntry.valueOf("queryStatus", "查询阀门状态", "无参数",null));
            commands.add(CommandEntry.valueOf("queryVoltage", "查询阀门电压", "无参数",null));
            return commands;
        }

        public IDevice createDevice(ICenterFacilities iCenterFacilities, DeviceEntity entity) {
            return new StandardV2Device (GatewayV2Server.getInstance ().getEngine (),this,iCenterFacilities,entity);
        }

        public Class<? extends StoreEntity> storeClass() {
            return StandardValveV2StoreEntry.class;
        }

        public String getId() {
            return "zhny-standard-valve-v2-plugin";
        }

        public String getName() {
            return "智慧标准阀门V2插件";
        }

        public FactoryType getType() {
            return FactoryType.ValveController;
        }


    }
}
